#include<stack>
#include<iostream>
using namespace std;
int main(){
	int n;
	stack<string>a,b;
	string s,w;
	cin>>n;
	while(n--){
		cin>>s;
		if(s[0]=='V'){
			cin>>w;
			a.push(w);
			cout<<w<<endl;
			while(!b.empty()) b.pop();
		}
		else if(s[0]=='B'){
			if(a.size()>1){
				b.push(a.top());
				a.pop();
				cout<<a.top()<<endl;
			}
			else {
				cout<<"Ignore\n";
		   }
		}
		else{
			if(!b.empty()){
				a.push(b.top());
				cout<<b.top()<<endl;
				b.pop();
			}
			else cout<<"Ignore\n";
		}
	}
	return 0;
}